<?php

namespace App;

use App\Scopes\StatusScope;
use App\Traits\TimeFormat;
use Illuminate\Database\Eloquent\Model;

class Tag extends Model {
	use TimeFormat;

	protected $fillable = [
		'tag_name', 'status',
	];

	protected $casts = [
		'status' => 'boolean',
	];

	public static function boot() {
		parent::boot();
		static::addGlobalScope(new StatusScope());
	}

	public function items() {
		return $this->belongsToMany(Item::class, 'tagables');
	}
}
